home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / util / time / EZCron.lha / EZCronGUI < prev    next >
Text File  |  1996-10-10  |  32KB  |  1,105 lines

  1. /* EZCronGUI v1.72 by Jim Hines. ©1995-96 All Rights Reserved.
  2. ** Internet email me at <hines_j@wvlink.mpl.com>
  3. ** EZCronGUI is The Graphic User Interface for EZCron, ©1994-1996 Jim Hines.
  4. **
  5. ** 12-13-95 Added Speech Function to test subrtn.
  6. ** 12-22-95 Added Purge Function.
  7. ** 12-24-95 Added multi-windowing on prefs window
  8. ** 12-31-95 Added multi-windowing cyclegads on time and date fields
  9. **             Changed the main gui interface window and moved the new config
  10. **            button to the edit screen. Removed the Quik Add button altogether.
  11. ** 01-05-96 Added Weekdays, Weekends and Quarterly support.
  12. **             Added full online help subroutine.
  13. ** 01-07-96 Added Default Event Variable Handling. Opens prefs file at beginning
  14. **            and rereads it with the 'addefault' command.
  15. **            added online help for def event button.
  16. ** 08-25-96 Changes the cron.config file to reside in envarc: and RAM:ENV
  17. **            Great idea Paul. ;)
  18. ** 09-02-96 Moved the active config file to ram:t as the env: was causing HD
  19. **          activity with such programs as HDEnv. The cron.config is now BACK
  20. **            in s: but copied to t:
  21. ** 09-09-96 Started work on the range stuffs
  22. ** 09-10-96 Hourly time range routine added.
  23. ** 09-11-96 Fixed a few bugs and tightened the code up a bit.
  24. ** 09-18-96 Added the every 5 minutes time field.
  25. ** 10-10-96 Fixed a nasty clock bug in the I/O button which caused the GUI to exit.
  26. **          This occured after being in the event editor, then exiting to the
  27. **            control panel and then quiting the daemon.
  28. */
  29.  
  30. LF= '0a'x
  31. options results
  32.  
  33. address command 'copy s:cron.config t:'
  34.  
  35.     if ~show("L","rexxsupport.library") then
  36.            call addlib("rexxsupport.library", 0, -30)
  37.     
  38.     if ~show('L','rexxreqtools.library') then
  39.            call addlib("rexxreqtools.library", 0, -30, 0)
  40.         
  41.     if ~showlist( 'p', 'VAREXX' ) then do
  42.            address command 'run >nil: varexx'
  43.         call delay(25)
  44.         waitforport
  45.         waitforport
  46.     end
  47.  
  48.     address VAREXX
  49.     call openport("MAINWINPORT")  
  50.     load 'EZCron:EZC.gui MAINWINPORT'      
  51.     host = result     
  52.     address value host
  53.     show project0     
  54.  
  55. startup:
  56.  
  57.     if showlist('P', 'EZCRON_REXX') then do
  58.         settext text '"EZCron Daemon is Running"'
  59.     end
  60.  
  61.     if ~showlist('P', 'EZCRON_REXX') then do
  62.         settext text '"EZCron Daemon is NOT Running"'
  63.     end
  64.  
  65. /* ===== MAIN LOOP =======*/
  66. mainloop:
  67.  
  68.     do forever    /* Wait for the user to close the window */
  69.         settext datewin Date(USA)
  70.         setlist eventlist clear  /* CLEAR THE LISTVIEW WINDOW */
  71.  
  72.  
  73. /* ===== READ AND PARSE THE CONFIG FILE ===== */
  74.  
  75.         config = 's:cron.config'        /* Name of file for reading events from */
  76.         event. = 0
  77.  
  78.         if ~open(cronfile, config,'READ') then do
  79.             call message('No s:cron.config file present....exiting.')
  80.             exit 20
  81.         end
  82.  
  83.         errors = 0
  84.  
  85.         do until eof(cronfile)
  86.             /* Grab the line, parse the event and ignore the comments */
  87.             linein = readln(cronfile)
  88.             parse var linein line '#'
  89.  
  90.             next = event.0 + 1
  91.  
  92.             parse var line event.next.command event.next.pargs1 event.next.pargs2,
  93.             event.next.pargs3 event.next.pargs4 event.next.time event.next.date,
  94.             event.next.rng1 event.next.rng2 event.next.sfx event.next.txt
  95.  
  96.             event.next.date = translate(event.next.date, 'abcdefghijklmnopqrstuvwxyz',,
  97.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  98.                             /* THE ABOVE TRANSLATES THE DATE TO LOWERCASE IF NOT NUMERIC */
  99.  
  100.             event.next.time = translate(event.next.time, 'abcdefghijklmnopqrstuvwxyz',,
  101.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  102.                             /* THE ABOVE TRANSLATES THE TIME TO LOWERCASE IF NOT NUMERIC */
  103.  
  104.  
  105.             if line ~= '' then do  /* This keeps the commented out lines from appearing */
  106.                 setlist Eventlist event.next.command event.next.pargs1 event.next.pargs2 event.next.pargs3 event.next.pargs4 event.next.time event.next.date event.next.txt '************************'
  107.             end
  108.  
  109.             select
  110.                 when event.next.command = '' then iterate
  111.                 when event.next.command = '' then do
  112.                     iterate
  113.                 end
  114.                 otherwise event.0 = next
  115.             end
  116.         end                                /* end of: do until EOF */
  117.         call close(cronfile)
  118.  
  119. /* =====END OF PARSE SECTION == */
  120.  
  121.         do forever  /* THIS DO LOOP CONTROLS THE CLOCK AND CHECKS FOR A PACKET */
  122.             packet = getpkt( "MAINWINPORT" )
  123.             clock = time('N')         /* THIS IS THE TIME WITH SECONDS IN 24HR */
  124.             clock2 = LEFT(clock,5)    /* THIS GET RID OF THE SECONDS */
  125.             sec = right(clock, 2)  /* Get Seconds */
  126.             settext time clock
  127.             call delay(48)
  128.  
  129.             if packet ~= '00000000'x then do /* This is not a null message */
  130.                 class  = getarg(packet)    /* Get the information about the message */
  131.                     type = word(class, 1)
  132.                     msg = substr(class, 1,9) 
  133.                 call classes()
  134.             end
  135.         end
  136.  
  137.  
  138. classes:
  139.  
  140. /* =====CLASS CLOSEWINDOW ===== */
  141.         if class = closewindow then do
  142.             settext text 'Exiting EZCron'
  143.             call exiting() 
  144.         end
  145.  
  146. /* =====CLASS PAGEEDIT ===== */
  147.         if class = pageedit then call eventedit()
  148.  
  149.  
  150. /* =====CLASS AC_TOGGLE ===== */ 
  151.  
  152.         if class = AC_Toggle then do
  153.             if ~showlist('P', 'EZCRON_REXX') then do    
  154.                 address command 'run >nil: rx >nil: EZCron start'
  155.                 waitforport
  156.                 settext text '"EZCron Daemon is running."'
  157.                 call mainloop()
  158.             end    
  159.             else
  160.                 if showlist('P', 'EZCRON_REXX') then do    
  161.                 address command 'run >nil: rx >nil: EZCron stop'
  162.                 busy set /* Turn on busy pointer */
  163.             
  164.                 do until ~showlist('P', 'EZCRON_REXX')
  165.                     clock = time('N')
  166.                     sec = right(clock, 2)  /* Get Seconds */
  167.                     sec2 = 60 - sec        /* 60 (seconds) minus sec) */
  168.                     if sec2 = 60 then sec2 = 00
  169.                     settext text '"Exiting daemon in:"' sec2 'seconds.'
  170.                     settext time clock
  171.                     call delay(49)
  172.                 end
  173.                 settext text '"EZCron Daemon is NOT Running"'
  174.             end
  175.         busy /* Turn off Busy Pointer */
  176.         call mainloop()
  177.         end
  178.     end         /* End of first big do forever loop */
  179.  
  180. /* ===== EDITEVENT SUBROUTINE ========= */
  181.  
  182. eventedit:
  183.     hide
  184.     show editwindow
  185.     set sortgad blankgad1 disable
  186.  
  187. eventparse:
  188.     address value host  /* this is so the correct window's buttons work after closing other windows */
  189.     drop ev et ed arg1 arg2 arg3 arg4 sfx txt field /* this drops any variables that may be present */
  190.  
  191.     do forever
  192.         setlist selectevent clear
  193.         config = 's:cron.config'    /* Name of file for reading events from */
  194.         event. = 0
  195.     
  196.         if ~open(cronfile, config,'READ') then do
  197.             call message('No s:cron.config file present....exiting.')
  198.             exit 20
  199.         end
  200.     
  201.         errors = 0
  202.         do until eof(cronfile)
  203.             linein = readln(cronfile)
  204.             parse var linein line '#'
  205.             next = event.0 + 1
  206.     
  207.             parse var line event.next.command event.next.pargs1 event.next.pargs2,
  208.             event.next.pargs3 event.next.pargs4 event.next.time    event.next.date,
  209.             event.next.rng1 event.next.rng2 event.next.sfx event.next.txt
  210.  
  211.             event.next.date = translate(event.next.date, 'abcdefghijklmnopqrstuvwxyz',,
  212.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  213.                             /* THE ABOVE TRANSLATES THE DATE TO LOWERCASE IF NOT NUMERIC */
  214.  
  215.             event.next.time = translate(event.next.time, 'abcdefghijklmnopqrstuvwxyz',,
  216.                             'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  217.                             /* THE ABOVE TRANSLATES THE TIME TO LOWERCASE IF NOT NUMERIC */
  218.  
  219.  
  220.             event.next.txt = strip(event.next.txt) /* This Gets rid of the leading & trailing spaces in the LAST variable
  221.                                                       If new fields are added, the variable must be changed to reflect this */
  222.     
  223.             if line ~= '' then do  /* This keeps the commented out lines from appearing */
  224.                 setlist selectevent event.next.command
  225.             end
  226.         
  227.             select
  228.                 when event.next.command = '' then iterate
  229.                 when event.next.command = '' then do
  230.                     iterate
  231.                 end
  232.                 otherwise event.0 = next
  233.             end
  234.         end
  235.         call close(cronfile)
  236.  
  237. /* ===== END OF PARSE  */
  238.  
  239. waitforpkt:
  240.         call waitpkt( "MAINWINPORT" )    /* Wait for a message from Varexx */
  241.         packet = getpkt( "MAINWINPORT" )        /* Get the message */
  242.  
  243.            if packet ~= '00000000'x then do /* This is not a null message */
  244.             class  = getarg(packet)    /* Get the information about the message */
  245.                type = word(class, 1)
  246.                msg = substr(class, 12,100)
  247. /*            say 'Message Var = ' msg           DEBUG STUFF
  248.             say 'Class Var = ' class
  249.             say 'Type Var = ' type
  250. */
  251. /* ===== CLASS EXIT EDITOR ===== */
  252.             if class = end then do /* This is the exit button */
  253.                 hide
  254.                 show project0
  255.                 call startup()
  256.             end
  257.  
  258. /* ===== CLASS QUIT PROGRAM ===== */
  259.  
  260.             if class = closewindow then call exiting()
  261.  
  262. /* ===== CLASS MAINHELP CHECK ===== */
  263.  
  264.             if class = 'MAINHELP TRUE' then call mainhelp()
  265.  
  266.  
  267. /* ===== CLASS PREFSGAD ===== */
  268.  
  269.             if class = prefsgad then do
  270.                 call openport(PREFSWINPORT)
  271.                 spawn PREFSWINPORT
  272.                 host2 = result
  273.                 address value host2
  274.                 show prefswindow
  275.                 call prefs()
  276.             end
  277.  
  278. /* ===== CLASS EDIT ===== */        
  279.             if class = EDIT then do
  280.                 if ~exists('EZCron:prefs/txted.prefs') then address command 'ed s:cron.config'
  281.                 if exists('EZCron:prefs/txted.prefs') then do
  282.                     open(edconfig, 'EZCron:prefs/txted.prefs', 'r')
  283.                     linein = readln(edconfig)
  284.                     address command linein 's:cron.config'
  285.                     close(edconfig)
  286.                 end
  287.                  address command 'copy s:cron.config ram:t' /* 9-02-96 */
  288.                 call eventparse()
  289.             end
  290.  
  291. /* ===== CLASS TEST EVENT ===== */
  292.  
  293.             if class = testevent then do
  294.                 if exists('EZCron:prefs/sfx.prefs') then do
  295.                     open(sfxconfig, 'EZCron:prefs/sfx.prefs', 'r')
  296.                     sfxplayer = readln(sfxconfig)
  297.                     close(sfxconfig)
  298.                 end
  299.  
  300.                 read event
  301.                 ev = RESULT
  302.     
  303.                 read arg1
  304.                 arg1 = RESULT
  305.                 if arg1 = '-' then arg1 = ''
  306.     
  307.                 read arg2
  308.                 arg2 = RESULT
  309.                 if arg2 = '-' then arg2 = ''
  310.  
  311.                 read arg3
  312.                 arg3 = RESULT
  313.                 if arg3 = '-' then arg3 = ''
  314.  
  315.                 read arg4
  316.                 arg4 = RESULT
  317.                 if arg4 = '-' then arg4 = ''
  318.  
  319.                 read sfx
  320.                 fx = RESULT
  321.                 if fx = '-' then fx = ''
  322.     
  323.                 read txtstr
  324.                 tx = result
  325.                 
  326.                 if ev ~= textreminder then do
  327. /*                    address command 'run >nil: 'ev arg1 arg2 arg3 arg4*/
  328.                     address command 'run >con:100/100/300/100/CronTestEvent/Close' ev arg1 arg2 arg3 arg4
  329.                 end
  330.     
  331.                 if fx ~= '' then do
  332.                         address command 'run >nil:' sfxplayer fx
  333.                 end
  334.     
  335.                 if ev = TEXTREMINDER then do
  336.                     address command 'run >nil: rx >nil: ezcron:rexx/Reminder.rexx' tx
  337.                     if showlist(h,SPEAK) then do
  338.                         address command 'echo' tx '>speak:'
  339.                     end
  340.                 end
  341.     
  342.                 drop ev arg1 fx tx sfxplayer
  343.             end
  344.     
  345. /* ===== CLASS GETFILE ===== */
  346.  
  347.             if class = getfile then do
  348.                 clock = time('N')
  349.                 clock2 = LEFT(clock,5)
  350.                 filename = rtfilerequest(, , "Pick a File To Run",OK, "rt_reqpos = reqpos_centerscr")
  351.                 settext event filename
  352.                 settext event_time clock2
  353.                 settext event_date Date(USA)
  354.                 settext arg1 '-'
  355.                 settext arg2 '-'
  356.                 settext arg3 '-'
  357.                 settext arg3 '-'
  358.                 settext rng1 '--'
  359.                 settext rng2 '--'
  360.                 settext sfx '-'
  361.                 settext txtstr '-'
  362.             end
  363.  
  364. /* ===== CLASS NEW CONFIG ===== */ 
  365.         if class = AC_New then do
  366.             if exists('EZCron:prefs/cprefs') then do
  367.                 open(prefs, 'EZCron:prefs/cprefs', 'r')
  368.                 defevent = readln(prefs)
  369.                 close(prefs)
  370.             end
  371.             if ~exists('s:cron.config') then do
  372.                     open(MkCfg, 's:cron.config',W)
  373.                     writeln(MkCfg, defevent)
  374.                     address command 'copy s:cron.config ram:t' /* 9-02-96 */
  375.                     close(MkCfg)
  376.             end
  377.         else
  378.             call rtezrequest("A cron.config file already exists."||LF||"Do you wish to overwrite it?.", "_Yes|_No", , "rt_reqpos = reqpos_centerscr")
  379.             if rtresult == 1 then do
  380.                 if exists('s:cron.config.old') then address command 'delete s:cron.config.old'
  381.                 address command 'rename s:cron.config s:cron.config.old'
  382.                 call delay(3)
  383.                 open(MkCfg, 's:cron.config','w')
  384.                 writeln(MkCfg, defevent)
  385.                 close(MkCfg)
  386.             end
  387.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  388.         end     
  389.  
  390.     
  391. /* ===== CLASS REQUESTER GADS ===== */
  392.  
  393.             if class = arg1gad then do
  394.                 argname = rtfilerequest(, , "Pick a file argument",OK, "rt_reqpos = reqpos_centerscr")
  395.                 if argname = '' then argname = '-'
  396.                 settext arg1 argname
  397.             end
  398.     
  399.             if class = arg2gad then do
  400.                 argname = rtfilerequest(, , "Pick a file argument",OK, "rt_reqpos = reqpos_centerscr")
  401.                 if argname = '' then argname = '-'
  402.                 settext arg2 argname
  403.             end
  404.     
  405.             if class = arg3gad then do
  406.                 argname = rtfilerequest(, , "Pick a file argument",OK, "rt_reqpos = reqpos_centerscr")
  407.                 if argname = '' then argname = '-'
  408.                 settext arg3 argname
  409.             end
  410.     
  411.             if class = arg4gad then do
  412.                 argname = rtfilerequest(, , "Pick a file argument",OK, "rt_reqpos = reqpos_centerscr")
  413.                 if argname = '' then argname = '-'
  414.                 settext arg4 argname
  415.             end
  416.     
  417.             if class = sfxgad then do
  418.                 read sfx
  419.                 sfxtxt = result
  420.                 parse var sfxtxt device ':'
  421.                 if device = '-' then device = 'sys'
  422.                 argname = rtfilerequest(device':',, "Pick a soundfile",OK, "rt_reqpos = reqpos_centerscr")
  423.                 if argname = '' then argname = '-'
  424.                 settext sfx argname
  425.             end
  426.     
  427.             if class = txtgad then do
  428.                 read txtstr
  429.                 txt = result
  430.                 if txt = '-' then txt = '' 
  431.                 argname = rtgetstring(txt,'Enter Reminder String', 'Reminder Requester', ,'rt_reqpos = reqpos_centerscr')
  432.                 if argname = '' then call eventparse()
  433.                 clock = time('N')
  434.                 clock2 = LEFT(clock,5)
  435.                 settext txtstr argname
  436.                 settext event TextReminder
  437.                 settext event_time clock2
  438.                 settext event_date Date(USA)
  439.                 settext arg1 '-'
  440.                 settext arg2 '-'
  441.                 settext arg3 '-'
  442.                 settext arg3 '-'
  443.                 settext sfx '-'
  444.                 drop txt
  445.             end
  446.  
  447.             if class = datehelp then do
  448.                 call rtezrequest( " DATE HELP" || LF ||,
  449.                 " "    || LF ||,
  450.                 " These are possible date fields." || LF ||,
  451.                 " "    || LF ||,
  452.                 " "    || LF ||,
  453.                 " 01/01/95    * Run event once." || LF ||,
  454.                 " "    || LF ||,            
  455.                 " Mon-Fri     * Run event every " || LF ||,
  456.                 "               named day of week." || LF ||,
  457.                 " "    || LF ||,
  458.                 " Daily       * Run event every day." || LF ||,
  459.                 " "    || LF ||,
  460.                 " Weekdays    * Run event every" || LF ||,
  461.                 "               Monday-Friday only." || LF ||,
  462.                 " "    || LF ||,    
  463.                 " ", "More", ,)
  464.  
  465.  
  466.                 call rtezrequest( " DATE HELP" || LF ||,
  467.                 " "    || LF ||,
  468.                 " More possible date fields." || LF ||,
  469.                 " "    || LF ||,
  470.                 " "    || LF ||,
  471.                 " Weekend     * Run event every" || LF ||,
  472.                 "               Saturday & Sunday only." || LF ||,
  473.                 " "    || LF ||,    
  474.                 " Monthly-12  * Run event every month" || LF ||,
  475.                 "               on given date. The date" || LF ||,
  476.                 "               is specified AFTER the" || LF ||,
  477.                 "               hyphen." || LF ||,
  478.                 " "    || LF ||,
  479.                 " Every_#_ddd * This could actually be" || LF ||,
  480.                 "               typed as Every_3_Wed." || LF ||,
  481.                 "               That example would" || LF ||,
  482.                 "               execute an event every" || LF ||,
  483.                 "               3rd Wed. of the month." || LF ||,
  484.                 "               The '#' can be 1-5." || LF ||,
  485.                 "               The 'ddd' is a three" || LF ||,
  486.                 "               letter abbr. for day" || LF ||,
  487.                 "               of the week." || LF ||,
  488.                 " ", "Okay", ,)
  489.             call eventparse()
  490.             end
  491.  
  492.  
  493.             if class = timehelp then do
  494.                 call rtezrequest( " TIME HELP" || LF ||,
  495.                 " "    || LF ||,
  496.                 " These are possible time fields." || LF ||,
  497.                 " "    || LF ||,
  498.                 " "    || LF ||,
  499.                 " 14:40     * Run event at 2:40pm." || LF ||,
  500.                 " "    || LF ||,
  501.                 " Minute    * Run event once every" || LF ||, 
  502.                 "             minute." || LF ||,
  503.                 " Five_Min * Run event every 5" || LF ||,
  504.                 "             minutes." || LF ||,
  505.                 " Quarterly * Run event every 15" || LF ||,
  506.                 "             minutes." || LF ||,
  507.                 " Hourly    * Run event every hour" || LF ||,
  508.                 "             on the hour." || LF ||,
  509.                 " "    || LF ||,
  510.                 " ", "Okay", ,)
  511.             call eventparse()
  512.             end
  513.  
  514.             if class = rangehelp then do
  515.                 call rtezrequest( " RANGE HELP" || LF ||,
  516.                 " "    || LF ||,
  517.                 " This allows events to run within a time range." || LF ||,
  518.                 " Valid ranges could be:" || LF ||,
  519.                 " 18 - 24 for events from 6pm to midnight." || LF ||,
  520.                 " 00 - 05 for events from midnight to 5am." || LF ||,
  521.                 " " || LF ||,
  522.                 " See Docs for more detailed infomation." || LF ||,
  523.                 " ", "Okay", ,)
  524.             call eventparse()
  525.             end
  526.  
  527.  
  528.             if class = datefields then do
  529.                 call openport(DATEWINPORT)
  530.                 spawn DATEWINPORT
  531.                 host3 = result
  532.                 address value host3
  533.                 show datewindow
  534.                 call datefields()
  535.             end
  536.  
  537.             if class = timefields then do
  538.                 call openport(TIMEWINPORT)
  539.                 spawn TIMEWINPORT
  540.                 host4 = result
  541.                 address value host4
  542.                 show timewindow
  543.                 call timefields()
  544.             end
  545.  
  546. /* ===== CLASS PURGE EVENT ===== */
  547.             if class = purgegad then do
  548.  
  549.                 address command 'copy s:cron.config s:cron.config.old'
  550.                 address command 'delete s:cron.config'
  551.                 open(dfile, 's:cron.config', 'W') /* create it again*/
  552.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  553.                 close(dfile)
  554.  
  555.                 do i = 1 to event.0
  556.                     /*say event.i.date*/
  557.                     parse var event.i.date month '/' day '/' year
  558.                     
  559.                     if day ~= '' & if year ~= '' then do 
  560.                         sortdate = '19'year''month''day
  561.                         eventdate = date('c',sortdate,'s')        /* number of days since..*/
  562.  
  563.                         currentdate = date(s) /* 19951221 */
  564.                         sortcurrent = date('c', currentdate, 's') /* number of days since..*/
  565.                         a = sortcurrent-eventdate
  566.                         /*say 'a equals =' a*/
  567.                         if a > 0 then event.i.command = delete  /* this are the files you DONT want to write */
  568.                     end
  569.  
  570.                     if event.i.command ~= delete then do    
  571.                         open(dfile, 's:cron.config', 'a')
  572.                         writeln(dfile, event.i.command event.i.pargs1, 
  573.                         event.i.pargs2 event.i.pargs3 event.i.pargs4,
  574.                         event.i.time event.i.date event.i.rng1,
  575.                         event.i.rng2 event.i.sfx event.i.txt)
  576.                         drop result
  577.                     end
  578.                     close(dfile)
  579.                     address command 'copy s:cron.config ram:t' /* 9-02-96 */
  580.                     drop total
  581.                 end
  582.             end
  583.  
  584. /* ===== CLASS UPDATE (MODIFY) EVENT ===== */
  585.             if class = update then do
  586.  
  587.                 read event
  588.                 ev = result
  589.                 if ev = '' then call message('No Event Field.')
  590.                 if ev = '' then call eventparse()
  591.                 if ev = 'None Selected' then call message('No Event Field.')
  592.                 if ev = 'None Selected' then call eventparse()
  593.  
  594.                  event.en.command = ''
  595.                 event.en.time = ''
  596.                 event.en.date = ''
  597.                 event.en.pargs1 = ''
  598.                 event.en.pargs2 = ''
  599.                 event.en.pargs3 = ''
  600.                 event.en.pargs4 = ''
  601.                 event.en.rng1 = ''
  602.                 event.en.rng2 = ''
  603.                 event.en.sfx = ''
  604.                 event.en.txt = ''
  605.     
  606.                 address command 'copy s:cron.config s:cron.config.old'
  607.                 address command 'delete s:cron.config'
  608.                 open(dfile, 's:cron.config', 'W') /* create it again*/
  609.                 close(dfile)
  610.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  611.     
  612.                 read selectevent var h
  613.                 open(dfile, 's:cron.config', 'a')
  614.                 do n = 1 to h.count
  615.                     if event.n.time = '' then h.n = delete
  616.  
  617.                     if h.n ~= delete then
  618.                     writeln(dfile, h.n event.n.pargs1 event.n.pargs2,
  619.                     event.n.pargs3 event.n.pargs4 event.n.time,
  620.                     event.n.date event.n.rng1 event.n.rng2,
  621.                     event.n.sfx event.n.txt)
  622.                     drop result
  623.                 end
  624.                 close(dfile)
  625.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  626.  
  627.                 read event
  628.                 ev = result
  629.                 if ev = '' then call message('No Event Field.')
  630.                 if ev = '' then call eventparse()
  631.                 if ev = 'None Selected' then call message('No Event Field.')
  632.                 if ev = 'None Selected' then call eventparse()
  633.                 
  634.                 read event_time
  635.                 et = result
  636.                 if et = '' then    call message('No Time Field.')
  637.     
  638.                 read event_date
  639.                 ed = result
  640.                 if ed = '' then call message('No Date Field.')
  641.  
  642.                  read arg1
  643.                 arg1 = result
  644.                 if arg1 = '' then arg1 = '-'
  645.                 read arg2
  646.                 arg2 = result
  647.                 if arg2 = '' then arg2 = '-'
  648.                  read arg3
  649.                 arg3 = result
  650.                 if arg3 = '' then arg3 = '-'
  651.                 read arg4
  652.                 arg4 = result
  653.                 if arg4 = '' then arg4 = '-'
  654.  
  655.                 read rng1
  656.                 rng1 = result
  657.                 if rng1 = '' then rng1 = '--'
  658.  
  659.                 read rng2
  660.                 rng2 = result
  661.                 if rng2 = '' then rng2 = '--'
  662.     
  663.                 read sfx
  664.                 sfx = result
  665.                 if sfx = '' then sfx = '-'
  666.     
  667.                 read txtstr
  668.                 txt = result
  669.                 if txt = '' then txt = '-'
  670.                 
  671.                 open(dfile, 's:cron.config', 'a')
  672.                 writeln(dfile, ev arg1 arg2 arg3 arg4 et ed rng1 rng2 sfx txt)
  673.                 close(dfile)
  674.                 drop ev et ed arg1 arg2 arg3 arg4 rng1 rng2 sfx txt
  675.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  676.             end
  677.  
  678.  
  679.  
  680. /* ===== CLASS ADDEVENT ===== */
  681.  
  682.             if class = addevent then do
  683.                 read event
  684.                 ev = result
  685.                 if ev = '' then call message('No Event Field.')
  686.                 if ev = 'None Selected' then call message('No Event Field.')
  687.                 
  688.                 read event_time
  689.                 et = result
  690.                 if et = '' then    call message('No Time Field.')
  691.     
  692.                 read event_date
  693.                 ed = result
  694.                 if ed = '' then call message('No Date Field.')
  695.         
  696.                  read arg1
  697.                 arg1 = result
  698.                 if arg1 = '' then arg1 = '-'
  699.                 read arg2
  700.                 arg2 = result
  701.                 if arg2 = '' then arg2 = '-'
  702.                  read arg3
  703.                 arg3 = result
  704.                 if arg3 = '' then arg3 = '-'
  705.                 read arg4
  706.                 arg4 = result
  707.                 if arg4 = '' then arg4 = '-'
  708.  
  709.                 read rng1
  710.                 rng1 = result
  711.                 if rng1 = '' then rng1 = '--'
  712.  
  713.                 read rng2
  714.                 rng2 = result
  715.                 if rng2 = '' then rng2 = '--'
  716.     
  717.                 read sfx
  718.                 sfx = result
  719.                 if sfx = '' then sfx = '-'
  720.     
  721.                 read txtstr
  722.                 txt = result
  723.                 if txt = '' then txt = '-'
  724.                 
  725.                 if ev = '' then call eventparse()
  726.                 if ev = 'None Selected' then call eventparse()
  727.                 if et = '' then call eventparse()
  728.                 if ed = '' then call eventparse()
  729.  
  730.                 open(dfile, 's:cron.config', 'a')
  731.                 writeln(dfile, ev arg1 arg2 arg3 arg4 et ed rng1 rng2 sfx txt)
  732.                 close(dfile)
  733.                 drop ev et ed arg1 arg2 arg3 arg4 rng1 rng2 sfx txt
  734.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  735.             call eventparse()
  736.             end
  737.             
  738.  
  739. /* ===== CLASS ADDEFAULT EVENT ===== */
  740.  
  741.             if class = addefault then do
  742.                 read event
  743.                 ev = result
  744.                 if ev = '' then call message('No Event Field.')
  745.                 if ev = 'None Selected' then call message('No Event Field.')
  746.                 
  747.                 read event_time
  748.                 et = result
  749.                 if et = '' then    call message('No Time Field.')
  750.     
  751.                 read event_date
  752.                 ed = result
  753.                 if ed = '' then call message('No Date Field.')
  754.         
  755.                  read arg1
  756.                 arg1 = result
  757.                 if arg1 = '' then arg1 = '-'
  758.                 read arg2
  759.                 arg2 = result
  760.                 if arg2 = '' then arg2 = '-'
  761.                  read arg3
  762.                 arg3 = result
  763.                 if arg3 = '' then arg3 = '-'
  764.                 read arg4
  765.                 arg4 = result
  766.                 if arg4 = '' then arg4 = '-'
  767.  
  768.                 read rng1
  769.                 rng1 = result
  770.                 if rng1 = '' then rng1 = '--'
  771.  
  772.                 read rng2
  773.                 rng2 = result
  774.                 if rng2 = '' then rng2 = '--'
  775.     
  776.                 read sfx
  777.                 sfx = result
  778.                 if sfx = '' then sfx = '-'
  779.     
  780.                 read txtstr
  781.                 txt = result
  782.                 if txt = '' then txt = '-'
  783.                 
  784.                 if ev = '' then call eventparse()
  785.                 if ev = 'None Selected' then call eventparse()
  786.                 if et = '' then call eventparse()
  787.                 if ed = '' then call eventparse()
  788.  
  789.                 address command 'delete ezcron:prefs/cprefs'
  790.                 open(dfile, 'ezcron:prefs/cprefs', 'w')
  791.                 writeln(dfile, ev arg1 arg2 arg3 arg4 et ed rng1 rng2 sfx txt)
  792.                 close(dfile)
  793.                 drop ev et ed arg1 arg2 arg3 arg4 rng1 rng2 sfx txt
  794.             call eventparse()
  795.             end
  796.             
  797.  
  798. /* ===== SELECTEVENT ===== */            
  799.  
  800.             if msg ~= '' & type = 'SELECTEVENT' then do
  801.     
  802.                 settext event msg
  803.                 read selectevent NUMBER
  804.                 en = RESULT  /* en is the event number */
  805.                 /*say 'en = ' en*/
  806.                                     
  807.                 settext event_time event.en.time
  808.                 settext event_date event.en.date
  809.                 settext arg1 event.en.pargs1
  810.                 settext arg2 event.en.pargs2
  811.                 settext arg3 event.en.pargs3
  812.                 settext arg4 event.en.pargs4
  813.                 settext rng1 event.en.rng1
  814.                 settext rng2 event.en.rng2
  815.                 settext sfx event.en.sfx
  816.                 settext txtstr event.en.txt
  817.     
  818. /*                say 'event.en.sfx =' event.en.sfx   DEBUG ROUTINES COMMENTED OUT
  819.                 say 'event.en.txt =' event.en.txt
  820.                 say 'event.0 = ' event.0
  821. */
  822.             end
  823.     
  824. /* ===== CLASS DELETE EVENT ===== */
  825.  
  826.             if class = delete_event then do
  827.                 event.en.command = ''
  828.                 event.en.time = ''
  829.                 event.en.date = ''
  830.                 event.en.pargs1 = ''
  831.                 event.en.pargs2 = ''
  832.                 event.en.pargs3 = ''
  833.                 event.en.pargs4 = ''
  834.                 event.en.rng1 = ''
  835.                 event.en.rng2 = ''
  836.                 event.en.sfx = ''
  837.                 event.en.txt = ''
  838.     
  839.                 address command 'copy s:cron.config s:cron.config.old'
  840.                 address command 'delete s:cron.config'
  841.                 open(dfile, 's:cron.config', 'W') /* create it again*/
  842.                 close(dfile)
  843.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  844.     
  845.                 read selectevent var h
  846.                 open(dfile, 's:cron.config', 'a')
  847.                 do n = 1 to h.count
  848.                     if event.n.time = '' then h.n = delete
  849.     
  850.                     if h.n ~= delete then
  851.                     writeln(dfile, h.n event.n.pargs1 event.n.pargs2,
  852.                     event.n.pargs3 event.n.pargs4 event.n.time,
  853.                     event.n.date event.n.rng1 event.n.rng2,
  854.                     event.n.sfx event.n.txt)
  855.                     drop result
  856.                 end
  857.                 close(dfile)
  858.                 address command 'copy s:cron.config ram:t' /* 9-02-96 */
  859.     
  860.                 settext event 'None Selected'
  861.                 settext event_time 'NA'
  862.                 settext event_date 'NA'
  863.                 settext arg1 '-'
  864.                 settext arg2 '-'
  865.                 settext arg3 '-'
  866.                 settext arg3 '-'
  867.                 settext rng1 '--'
  868.                 settext rng2 '--'
  869.                 settext sfx '-'
  870.                 settext txtstr '-'
  871.                 
  872.                 call eventparse()
  873.             end /* Above routine end */
  874.         end        /* rexx portcheck end */
  875.     end            /* do forever main loop end */
  876.     exit        /* end of program....subs follow */
  877.  
  878.  
  879.  
  880.  
  881. /* ===== SUB-ROUTINES START HERE ==== */
  882.  
  883. /* ===== PREFERENCES ===== */
  884.  
  885. prefs:
  886.     set time_format date_format gadget42 disable
  887.     call waitpkt( "PREFSWINPORT" )    /* Wait for a message from Varexx */
  888.     packet = getpkt( "PREFSWINPORT" )        /* Get the message */
  889.  
  890.     if packet ~= '00000000'x then do /* This is not a null message */
  891.         class  = getarg(packet)    /* Get the information about the message */
  892.            type = word(class, 1)
  893.                msg = substr(class, 12,100)
  894.             /*say 'class =' class
  895.             say 'msg =' msg*/    DEBUG STUFF
  896.  
  897.             if class = 'CLOSEWINDOW PrefsWindow' then do  /* This is strange */
  898.                 hide
  899.                 call eventparse()
  900.             end
  901.  
  902.             if class = exitprefs then do
  903.                 hide
  904.                 call eventparse()
  905.             end
  906.     
  907.             if class = texteditor then do
  908.                 editor = rtfilerequest(, , "Pick a text editor",OK, "rt_reqpos = reqpos_centerscr")
  909.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  910.                 open(edconfig,'EZCron:prefs/txted.prefs', 'w')
  911.                 writeln(edconfig, editor)
  912.                 close(edconfig)
  913.                 drop editor
  914.             end
  915.                 
  916.             if class = sfxplayer then do
  917.                 player = rtfilerequest(, , "Pick a sound player",OK, "rt_reqpos = reqpos_centerscr")
  918.                 if rtresult == 0 then call prefs() /*This get out of the edprefs function */
  919.                 open(edconfig,'EZCron:prefs/sfx.prefs', 'w')
  920.                 writeln(edconfig, player)
  921.                 close(edconfig)
  922.                 drop player
  923.             end
  924.             call prefs()
  925.     end    
  926.  
  927. /* ===== DATE FIELD REQUESTER ===== */
  928.  
  929. datefields:
  930.     field = ''
  931.     do forever
  932.         call waitpkt( "DATEWINPORT" )    /* Wait for a message from Varexx */
  933.         packet = getpkt( "DATEWINPORT" )        /* Get the message */
  934.     
  935.         if packet ~= '00000000'x then do /* This is not a null message */
  936.             class  = getarg(packet)    /* Get the information about the message */
  937.                type = word(class, 1)
  938.             msg = substr(class, 11,25)
  939.  
  940.             if field = '' then field = date(usa)
  941.             /*say 'field before the if string is' field*/
  942.             if msg = '0' then field = Date(USA)
  943.             if msg = '1' then field = 'Daily'
  944.             if msg = '2' then field = 'Monthly-'right(date(S),2)  /* Monthly-13 */ 
  945.             if msg = '3' then field = 'Sunday'
  946.             if msg = '4' then field = 'Monday'
  947.             if msg = '5' then field = 'Tuesday'
  948.             if msg = '6' then field = 'Wednesday'
  949.             if msg = '7' then field = 'Thursday'
  950.             if msg = '8' then field = 'Friday'
  951.             if msg = '9' then field = 'Saturday'
  952.             if msg = '10' then field = 'Sunday'
  953.             if msg = '11' then field = 'Weekdays'
  954.             if msg = '12' then field = 'Weekend'
  955.             if msg = '13' then field = 'Every_1_Mon'
  956.         
  957.             if class = 'CLOSEWINDOW DateWindow' then do
  958.                 hide
  959.                 address value host
  960.                 call eventparse()
  961.             end
  962.     
  963.             if class = exitdate then do
  964.                 hide
  965.                 address value host
  966.                 call eventparse()
  967.             end
  968.  
  969.             if class = okay then do
  970.                 hide
  971.                 address value host
  972.                 settext event_date field
  973.                 call eventparse()
  974.             end
  975.         end    
  976.     end
  977.  
  978. /* ===== TIME FIELD REQUESTER ===== */
  979.  
  980. timefields:
  981.     field = ''
  982.     do forever
  983.         call waitpkt( "TIMEWINPORT" )    /* Wait for a message from Varexx */
  984.         packet = getpkt( "TIMEWINPORT" )        /* Get the message */
  985.     
  986.         if packet ~= '00000000'x then do /* This is not a null message */
  987.             class  = getarg(packet)    /* Get the information about the message */
  988.                type = word(class, 1)
  989.             msg = substr(class, 11,25)
  990.  
  991.             if field = '' then field = LEFT(time('N'),5)
  992.             if msg = '0' then field = LEFT(time('N'),5)
  993.             if msg = '1' then field = 'Minute'
  994.             if msg = '2' then field = 'Five_Min'
  995.             if msg = '3' then field = 'Quarterly'
  996.             if msg = '4' then field = 'Hourly'
  997.  
  998.             if class = 'CLOSEWINDOW timewindow' then do
  999.                 hide
  1000.                 address value host
  1001.                 call eventparse()
  1002.             end
  1003.     
  1004.             if class = exittime then do
  1005.                 hide
  1006.                 address value host
  1007.                 call eventparse()
  1008.             end
  1009.  
  1010.             if class = okay then do
  1011.                 hide
  1012.                 address value host
  1013.                 settext event_time field
  1014.                 call eventparse()
  1015.             end
  1016.  
  1017.         end    
  1018.     end
  1019.  
  1020.  
  1021. mainhelp:
  1022.     do forever
  1023.         call waitpkt( "MAINWINPORT" )    /* Wait for a message from Varexx */
  1024.         packet = getpkt( "MAINWINPORT" )        /* Get the message */
  1025.  
  1026.         if packet ~= '00000000'x then do /* This is not a null message */
  1027.             class  = getarg(packet)    /* Get the information about the message */
  1028.                type = word(class, 1)
  1029.                    msg = substr(class, 12,100)
  1030.             /*say 'class =' class
  1031.             say 'msg =' msg*/        DEBUG STUFF
  1032.  
  1033.             if class = 'MAINHELP TRUE' then call eventparse()
  1034.  
  1035.             if class = getfile then call helpmessage('Calls file requester.')
  1036.             if class = timehelp then call helpmessage('Time field help gadget.')
  1037.             if class = timefields then call helpmessage('Time fields cycle gadget.')
  1038.             if class = datehelp then call helpmessage('Date field help.')
  1039.             if class = rangehelp then call helpmessage ('Time Range field help.')
  1040.             if class = datefields then call helpmessage('Date fields cycle gadget')
  1041.             if class = arg1gad then call helpmessage('Calls requester for file arguments')
  1042.             if class = arg2gad then call helpmessage('Calls requester for file arguments')
  1043.             if class = arg3gad then call helpmessage('Calls requester for file arguments')
  1044.             if class = arg4gad then call helpmessage('Calls requester for file arguments')
  1045.             if class = sfxgad then call helpmessage('Selects a sound file.')
  1046.             if class = txtgad then call helpmessage('Adds a text string.')
  1047.             if class = addevent then
  1048.                 call rtezrequest("ADD AN EVENT TO THE LIST." || LF ||,
  1049.                 "You MUST fill in your fields" || LF ||,
  1050.                 "BEFORE pushing the ADD gadget." || LF ||,
  1051.                 " ", "OKay", ,)
  1052.  
  1053.             if class = ac_new then call helpmessage('Creates a new s:cron.config file.')
  1054.             if class = delete_event then call helpmessage('Removes event from the list.')
  1055.             if class = edit then call helpmessage('Calls an external text editor.')
  1056.             if class = update then
  1057.                 call rtezrequest("UPDATES THE SELECTED EVENT." || LF ||,
  1058.                 "Select the event you wish to modify." || LF ||,
  1059.                 "Make the modifications you wish." || LF ||,
  1060.                 "Click the Modif gadget." || LF ||,
  1061.                 " ", "OKay", ,)    
  1062.  
  1063.             if class = testevent then call helpmessage('Tests the selected event')
  1064.             if class = purgegad then call helpmessage('Removes old, one time events.')
  1065.             if class = prefsgad then call helpmessage('Calls up the preferences window.')
  1066.             if class = end then call helpmessage('Exits editor window.')
  1067.             if class = closewindow then call helpmessage('Quits EZCron.')
  1068. /*            if class = addefault then call helpmessage('Saves selected event as default event.')*/
  1069.             if class = addefault then
  1070.                 call rtezrequest("SAVES THE SELECTED (CURRENT)" || LF ||,
  1071.                 "EVENT AS THE DEFAULT EVENT." || LF ||,
  1072.                 " " || LF ||,
  1073.                 "Whenever you select the NEW" || LF ||,
  1074.                 "gadget, it always adds an event" || LF ||,
  1075.                 "to the newly created list. This" || LF ||,
  1076.                 "is the default event." || LF ||,
  1077.                 "This may be set to a past" || LF ||,
  1078.                 "date if you wish for nothing to" || LF ||,
  1079.                 "take place." || LF ||,
  1080.                 " ", "OKay", ,)    
  1081.  
  1082.         end
  1083.     end
  1084.  
  1085. helpmessage: procedure
  1086.  
  1087.     call rtezrequest( arg(1),'Okay!','EZCron Online Help','rtez_flags=ezreqf_centertext',)
  1088.     return
  1089.  
  1090. message: procedure
  1091.  
  1092.     call rtezrequest( arg(1),'Okay!','EZCron ERROR','rt_reqpos = reqpos_centerscr rtez_flags=ezreqf_centertext',)
  1093.     return
  1094.  
  1095.  
  1096. /* ===== EXIT AND CLEAN UP ===== */
  1097.  
  1098. exiting:
  1099.     address command 'run >nil: avail flush'
  1100.     'hide unload'  /* Hide the window and unload the gui file from memory */
  1101.     call delay(15)
  1102.     call closeport( "MAINWINPORT" )  /* Close the port */
  1103.     address command 'run >nil: vxc'
  1104. exit
  1105.